#ifndef __M_LOG_H__
#define __M_LOG_H__


#include<iostream>
#include<ctime>  

#define DBG_LEVEL 0
#define INF_LEVEL 1
#define ERR_LEVEL 2
#define DEFAULT_LEVEL DBG_LEVEL

#define GREEN   "\033[32m|LOGGING|\033[0m"
#define YELLOW  "\033[33m|LOGGING|\033[0m"
#define RED     "\033[31m|LOGGING|\033[0m"

//封装一个日志宏，通过日志宏进行日志的打印，在打印的信息前带有系统时间以及文件名和行号
#define LOG(str_level,color,level,format,...) {\
    if(level>=DEFAULT_LEVEL){\
     time_t t=time(nullptr);\
     struct tm* ptm=localtime(&t);\
     char tmp_time[32];\
     strftime(tmp_time,31,"%H:%M:%S",ptm);\
     printf("%s------[LogLevel:%s][Time:%s]|[Filename:%s————Line:%d]\t_" format "\n",color,str_level,tmp_time,__FILE__,__LINE__,##__VA_ARGS__);\
   }\
}

#define DLOG(format, ...) LOG("DBG",YELLOW, DBG_LEVEL, format, ##__VA_ARGS__)
// 信息日志宏
#define ILOG(format, ...) LOG("INFO",GREEN, INF_LEVEL, format, ##__VA_ARGS__)
// 错误日志宏
#define ELOG(format, ...) LOG("ERROR",RED, ERR_LEVEL, format, ##__VA_ARGS__)

#endif